import {ZJRequestConfig} from "@/services/types";

interface IUserInfo {
    id: number
    username: string
    nickName: string
    email: string
    sign: string | null
    photo: string | null
    gender: number
}

export interface IState {
    userInfo: IUserInfo
    addressList?: Array<IAddress>
    defaultAddress?: IAddress
}

interface ILoginParams {
    username: string,
    password: string
}

interface IRegisterParams {
    username: string
    password: string
    email: string
    code: string
}

interface IUpdateParams {
    id?: number
    email: string
    sign: string
    gender: number | string
    timestamp?: string
}

interface IGetAddressParams {
    id?: number
    needNavigate?: string
}

interface ISetAddressParams {
    needNavigate?: string
}

export interface IAddress {
    id?: number
    receiverProvince?: number
    receiverCity?: number
    receiverDistrict?: number
    receiverAddress?: string
    receiverName?: string
    receiverMobile?: string
    receiverPhone?: string
    receiverDefault?: number
    // receiverZip: null
    // userId: 34
}

interface IAddAddressParams {
    receiverAddress: string
    receiverProvince: number
    receiverCity: number
    receiverDistrict: number
    receiverName: string
    receiverMobile: string
    receiverPhone?: string
    receiveDefault?: number
}

interface IEditAddressForm {
    id: number
    receiverAddress?: string
    receiverProvince?: number
    receiverCity?: number
    receiverDistrict?: number
    receiverName?: string
    receiverMobile?: string
    receiveDefault?: number
}

interface IEditAddressParams {
    submitForm: IEditAddressForm
    needNavigate?: string
}

interface IEditDefaultAddressParams {
    addressId: number
}

interface IDeleteAddressParams {
    addressId: number
}

export interface IActions {
    getMyAction: (needNavigate?: string) => Promise<IUserInfo | null>
    resetMyAction: (needNavigate: string) => void
    setupMyAction: () => Promise<void>
    loginAction: (params: ILoginParams, extraConfig?: ZJRequestConfig) => Promise<boolean>
    registerAction: (params: IRegisterParams) => Promise<boolean>
    logoutAction: () => Promise<boolean>
    updateMyAction: (params: IUpdateParams) => Promise<boolean>
    getMyAddressAction: (params?: IGetAddressParams) => Promise<Array<IAddress> | IAddress | null>
    setAddressListAction: (params: ISetAddressParams) => Promise<boolean>
    addAddressAction: (params: IAddAddressParams) => Promise<boolean>
    editAddressAction: (params: IEditAddressParams) => Promise<boolean>
    editDefaultAddressAction: (params: IEditDefaultAddressParams) => Promise<boolean>
    deleteAddressAction: (params: IDeleteAddressParams) => Promise<boolean>
}
